package graphSample;

import java.util.HashMap;

import core.Entity;
import core.Graph;
import core.Process;

public class TestGraph {
	static public Graph getGraph(){
		Graph g = new Graph("TestGraph2");
		
		// Entities
		Entity e1 = new Entity(g, "State1");
		e1.addVariable("$x","INT");
		
		Entity e2 = new Entity(g, "State2");
		e2.addVariable("$y","INT");
		
		Entity e3 = new Entity(g, "State3");
		e3.addVariable("$u","INT");
		
		Entity e4 = new Entity(g, "State4");
		e4.addVariable("$v","INT");
		
		Entity e5 = new Entity(g, "State5");
		e5.addVariable("$a","INT");
		
		Entity e6 = new Entity(g, "State6");
		e6.addVariable("$b","INT");
		
		Entity e7 = new Entity(g, "State7");
		e7.addVariable("$c","INT");
		
		// Processes
		Process p1 = new Process(g, "Process1", "$x=$y+1");
		p1.addEntityIn(e1); p1.addEntityIn(e2);
		p1.addEntityOut(e3); p1.addEntityOut(e4);
		for(int i = 0; i<40; i++){
			p1.addEvalItem("$u=$x+$y");
			p1.addEvalItem("$v=$u");
		}
		
		Process p2 = new Process(g, "Process2", "$u>=10000");
		p2.addEntityIn(e3);
		p2.addEntityOut(e5);
		for(int i = 0; i<40; i++){
			p2.addEvalItem("$a=$u+10000");
		}
		
		Process p3 = new Process(g, "Process3", "$u<10000");
		p3.addEntityIn(e3);
		p3.addEntityOut(e6);
		for(int i = 0; i<40; i++){
			p3.addEvalItem("$b=$u-10000");
		}
		
		Process p4 = new Process(g, "Process4", "TRUE");
		p4.addEntityIn(e5); p4.addEntityIn(e6);
		p4.addEntityOut(e7);
		for(int i = 0; i<40; i++){
			p4.addEvalItem("$c=$a+$b");
		}
		
		//Add token in e1
		HashMap<String,String> token;
		for(int i=0;i<10000;i++){
			token = new HashMap<String,String>();
			token.put("$x", String.valueOf(i));
			e1.addToken(token);
		}
		
		//Add token in e2
		for(int i=0;i<10000;i++){
			token = new HashMap<String,String>();
			token.put("$y", String.valueOf(i));
			e2.addToken(token);
		}
		return g;
	}
}
